package JavaPractice;

import java.util.Scanner;
public class 寝室369 {
    public static void main(String args[]) {
        int i, j;
        int ages[] = new int[3];
        boolean found[] = new boolean[4];
        Scanner reader = new Scanner(System.in);
        for (i = 0; i < 3; i++) {
            ages[i] = reader.nextInt();
        }
        found[3] = false;
        for(i=1;i<100;i++)
        {
            for (j = 0; j < 3; j++) {
                found[j] = false;
            }
            for (j = 0; j < 3; j++) {
                if ((ages[j] + i) % 10 == 3) {
                    found[0] = true;
                }
                if ((ages[j] + i) % 10 == 6) {
                    found[1] = true;
                }
                if ((ages[j] + i) % 10 == 9) {
                    found[2] = true;
                }
            }
            if (found[0] && found[1] && found[2]) {
                found[3] = true;
                break;
            }
        }
        if (found[3]) {
            System.out.println(i);
        } else {
            System.out.println("so sad!");
        }
        reader.close();
    }
}
